﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PowerControl
{
    public class Utils
    {
        static public double wattTodB(double power)
        {
            return 10.0 * Math.Log10( power / 1.0 );
        }

        static public double dBToWatt(double power)
        {
            return Math.Pow(10.0, power / 10.0);
        }

        static public double frequencyToWavelength( double freq )
        {
            return (299792458.0 / freq);
        }

        static public double DegToRad(double deg)
        {
            return deg * (Math.PI / 180.0);
        }

        static public double RadToDeg(double rad)
        {
            return rad * (180.0 / Math.PI);
        }

        static public double ThermalNoise(double Bandwidth, double Temperature)
        {
            double boltzmann = 1.380650424 * Math.Pow(10.0,-23.0);
            double kelvin = 273.15 + Temperature;
            return boltzmann * kelvin * Bandwidth;
        }

        static public void ErrMsg(String msg)
        {
            System.Windows.Forms.MessageBox.Show(msg);
        }
    }
}
